/**
*  \file control_pump_unittest.c
*
*  \brief
*
*  \author Lu Fukui  fukui.lu@linde-china.com
*  \author Wu Pengzhan  pengzhan.wu@linde-china.com
*
*
*/

/*===============================================[ private includes  ]================================================*/
#include "control_pump_unittest.h"
#include "../test/test.h"
#include "../assertor/assertor.h"
#include "../pal/pal_mem.h"
#include "../control_pump/control_pump.h"



/*===============================================[ private defines   ]================================================*/

/*===============================================[ private datatypes ]================================================*/

/*===============================================[ private variables ]================================================*/


/*===============================================[ stub functions ]================================================*/
void STUB_control_pump_input_update(){}
void STUB_control_pump_parameter_update(){}
void STUB_pump_parameter_rx(U16 RxMsgData[4]){}
void STUB_pump_parameter_tx(U16 TxMsgData[4]){}
void STUB_start_timer(TIMER * timer, U16 period){}
void STUB_stop_timer(TIMER * timer){}
void STUB_update_timer(TIMER * timer){}
void STUB_control_pump_steer(){}
void STUB_control_pump_lift(){}
void STUB_control_pump_tilt(){}
void STUB_control_pump_aux1(){}
void STUB_control_pump_aux2(){}

static F32 STUB_ramp_control_arg2;
void STUB_ramp_control(S16 target_value, F32* current_value, S16 ramp_y, S16 ramp_up_x, S16 ramp_down_x)
{
   *current_value = STUB_ramp_control_arg2;
}

void STUB_output_max_rpm(){}
RC STUB_interpol_s16_s16_construct( struct interpol_s16_s16_obj *me, pal_size_t count, S16 const * p_x, S16 const * p_y ){return RC_SUCCESS;}
void STUB_batt_cutback_control(){}
void STUB_pump_motor_discharge_control(){}
/*================================================[ inline functions ]================================================*/

/*================================================[ public functions ]================================================*/

void control_pump_unittest_execute(enum test_mode mode, U32 random_seed)
{
   test_execute("control_pump_tilt unit test", mode, random_seed--)
   {
      disable_all = TRUE;
      pump.input.seat_switch_1 = 5;
      pump.input.tilt_switch = 6;
      tilt_target_rpm = 1;
      tilt_current_rpm = 2;
      pumpF.tiltFlag = TRUE;
      pump.parameter.TILT_RPM = 123;
      STUB_ramp_control_arg2 = 456;
      control_pump_tilt();
      test(0,"T1 tilt_target_rpm", tilt_target_rpm == 0);
      test(0,"T1 tilt_current_rpm", tilt_current_rpm == 0);
      test(0,"T1 pumpF.tiltFlag", pumpF.tiltFlag == FALSE);
      
      disable_all = FALSE;
      pump.input.seat_switch_1 = 4;
      pump.input.tilt_switch = 6;
      tilt_target_rpm = 1;
      tilt_current_rpm = 2;
      pumpF.tiltFlag = TRUE;
      pump.parameter.TILT_RPM = 123;
      STUB_ramp_control_arg2 = 456;
      control_pump_tilt();
      test(0,"T2 tilt_target_rpm", tilt_target_rpm == 0);
      test(0,"T2 tilt_current_rpm", tilt_current_rpm == 0);
      test(0,"T2 pumpF.tiltFlag", pumpF.tiltFlag == FALSE);
      
      disable_all = FALSE;
      pump.input.seat_switch_1 = 5;
      pump.input.tilt_switch = 6;
      tilt_target_rpm = 1;
      tilt_current_rpm = 2;
      pumpF.tiltFlag = FALSE;
      pump.parameter.TILT_RPM = 123;
      STUB_ramp_control_arg2 = 0;
      control_pump_tilt();
      test(0,"T3 tilt_target_rpm", tilt_target_rpm == 123);
      test(0,"T3 tilt_current_rpm", tilt_current_rpm == 0);
      test(0,"T3 pumpF.tiltFlag", pumpF.tiltFlag == FALSE);
      
      disable_all = FALSE;
      pump.input.seat_switch_1 = 5;
      pump.input.tilt_switch = 5;
      tilt_target_rpm = 1;
      tilt_current_rpm = 2;
      pumpF.tiltFlag = TRUE;
      pump.parameter.TILT_RPM = 123;
      STUB_ramp_control_arg2 = 0;
      control_pump_tilt();
      test(0,"T4 tilt_target_rpm", tilt_target_rpm == 0);
      test(0,"T4 tilt_current_rpm", tilt_current_rpm == 0);
      test(0,"T4 pumpF.tiltFlag", pumpF.tiltFlag == FALSE);
      
      disable_all = FALSE;
      pump.input.seat_switch_1 = 5;
      pump.input.tilt_switch = 6;
      tilt_target_rpm = 1;
      tilt_current_rpm = 2;
      pumpF.tiltFlag = TRUE;
      pump.parameter.TILT_RPM = 123;
      STUB_ramp_control_arg2 = 1;
      control_pump_tilt();
      test(0,"T5 tilt_target_rpm", tilt_target_rpm == 123);
      test(0,"T5 tilt_current_rpm", tilt_current_rpm == 1);
      test(0,"T5 pumpF.tiltFlag", pumpF.tiltFlag == TRUE);
   }
}

/*===============================================[ private functions ]================================================*/

/***********************************************************************************************************************
*                             Copyright 2018 Linde Material Handling. All rights reserved.                             *
***********************************************************************************************************************/
